"use strict";

define(['common/js/service/seat-util',
    'common/js/boss-frame-angular-dev-0.1',
    'common/js/service/pms-common-service-0.1',
    'common/js/service/oss-common-service-0.1',
    'common/js/service/mplus-util'], function () {
    diretiveModule.directive('plusSeat', function (SeatUtil,PmsCommonService,OssCommonService, ProjectShareData, MaiDialog) {
        return {
            scope: {
                eventId: '@',
                tool: '@',
                loadOnStartup: '@',
                seatConfig: '=',
                invertModelChange: '&',
                afterLoad: '&',
                beforeSelect: '&',
                onSelect: '&',
                afterSelect: '&',
                reversedSelect:'&',
                lockPage:'@',
                // 需要显示状态的座位ID集合
                statefulSeats : '=',
                // 渠道ID
                channelId: '@',
                // 订单ID
                orderId: '@',
                // 预订单ID
                advanceOrderId: '@',
                // 门店购物车类型
                shoppingCartType:'@'
                	
            },
            restrict: "E",
            replace: true,
            transclude: true,
            compile: function (tElm, tAttrs) {
                if (!tAttrs.eventId) {
                    console.error("请指定属性event-id");
                    return;
                }
                if (!tAttrs.mapName) {
                    console.error("请指定属性map-name");
                    return;
                }

                return {
                    pre: function ($scope, elem, attrs) {
                        var seatConfig,
                            selectSeatNum,//选中座位的数量
                            currentSelectSeatInfo,
                            selectSeatIdInfo,//选中的座位ID与座位信息的映射关系
                            seatIdInfo,//所有座位ID与座位信息的映射关系
                            resourceIdInfo;//所有静态资源ID与座位信息的映射关系
                        
                        $scope.saleGoodInfo = {};

                        //高度自适应，最小高度450
                        var svg_min_height, svg_exclude_height, svg_exclude_height_full;

                        // 鼠标操作临时变量
                        var mDownClientX, mDownClientY, mMoveClientX, mMoveClientY, mUpClientX, mUpClientY,
                            mDownTx, mDownTy, mDownRectX, mDownRectY,
                            leftRegionSelect, rightDragFlag, mouseWheelFlag;

                        // 缩略图操作临时变量
                        var mDownClientX2, mDownClientY2, mDownTx2, mDownTy2, rightDragFlag2;

                        // 滚动条禁止 临时变量
                        var oldonmousewheel, isDisabled;

                        // HTML及SVG DOM
                        var svg_seat, floorGEl, bottomLayer, seatLayer, svg_thumbnail, floorGEl2, bottomLayer2, thumbnailSelector, seatSelector;

                        //座位SVG相关参数
                        var svg_params;
                        var defaultTransform = {
                                tx: 0,
                                ty: 0,
                                scale: 1
                            },
                            currentTransform, currentTransform2;
                        var transFormDefault = SeatUtil.INIT_TRANSFORM_STR;
                        var SVG_NS = SeatUtil.SVG_NS;
                        var SVG_XLINK = SeatUtil.XLINK;
                        var SEAT_TYPE = {
                            LOCK: 1,
                            PRESERVE: 2,
                            SELLING: 3,
                            SOLD: 4,
                            UNION: 5,//联票
                            COUPON: 6,//套票
                            REVTICKET:7 //保留票
                            
                        };
                        var ICON_ID = {
                            SELECT: 'select_icon',
                            LOCK: 'lock_icon',
                            LOCK_GRAY: 'lock_icon_gray',
                            SELLING: 'selling_icon',
                            UNION: 'union_icon',
                            PRESERVE: 'preserve_icon',
                            COUPON: 'coupon_icon',
                            REVC:'site_ticket', //场馆保留票
                            REVJ:'machice_ticket' //场馆机位票
                        };
                        var loadSeatMapCount = 0;

                        if ($scope.loadOnStartup != 'false' && $scope.loadOnStartup != false) {
                            loadSeatMap();
                        }

                        $scope.priceList = [];
                        $scope.priceCoupons = [];
                        $scope.seatClasses = [];
                        $scope.selectTypeInfo = ['选择方式','点选','排选','单号排选','双号排选'];
                        $scope.selectTypeInfoShow = [false,true,true,true,true]; //选择方式是否显示,默认都显示,可以通过外部指定
                        $scope.showReserveTicketModel = false;  //是否是保留票的模式选择,依然沿用正反选的选项
                        $scope.reverseTicketTypes=[{'id':1,'name':'剧院保留票'},{'id':2,'name':'技术预留票'}];
                        $scope.reverseTicketSelect=$scope.reverseTicketTypes[0];
                        
                        /***
                         * 选择保留票类型后触发
                         */
                        $scope.reverseChange=function(reverseTicketSelect){
                    	   $scope.reversedSelect({reverseType:reverseTicketSelect});
                        };
                        
                        
                        function loadSeatMap() {
                            //组件配置
                            seatConfig = {
                                heightMin: 110,// 最小高度
                                heightExclude: 160,// 排除高度
                                heightExcludeFull: 50,// 全屏排除高度
                                showSeatState: true,//是否加载座位状态（除位置信息之外的所有信息）
                                showSaleState: true,//是否加载销售状态
                                selectable: true,//是否可以框选，true|false
                                selectType: 1,//选择方式-->0|1|2|3|4(0框选1点选2排选3单排4双排)
                                selectInvertType: 0,//反选方式-->0|1(0不使用反选选项，选中之后再选择 1使用反选选项)
                                showType: [0, 1, 2, 3, 4, 5],//控制工具栏中子工具栏的显示状态-->[0,1,2,3,4,5]
                                seatType : [SEAT_TYPE.UNION,SEAT_TYPE.COUPON], //LOCK: 1, PRESERVE: 2, SELLING: 3, SOLD: 4, UNION: 5, COUPON: 6
                                selectMaxCount: 50,//正整数，-1：没有限制
                                selectMaxTip: "本项目一次最多可选购50个座位！",//提示
                                excludeCondition : false,//加载时需要排除的座位
                                initSelectCondition: true,//afterLoad回调返回的座位的选中条件
                                selectCondition: true,//选中的条件-->由seatInfo的属性组成条件表达式
                                selectStyleType: 1,//选中后样式类型-->0|1(0:颜色值-16进制，1:svg图形-15*15，位于座位正中间,3保留票)
                                selectStyle: 'select_icon',//选中后的样式-->颜色值|path(15*15)，默认打对勾
                                showReversedTicket:false, //是否显示保留票(备注解决,生产系统普通座位图中显示保留票)
                                allowSaleRevTicket:false  //当前操作员是否允许销售保留票
                            };

                            setSeatConfig($scope.seatConfig);
                            
                            
                            //处理选择方式的选择add by 陈波
                            if($scope.seatConfig.selectTypeExclude){
                            	for(var k in $scope.seatConfig.selectTypeExclude){
                            		var excludeIndex=$scope.seatConfig.selectTypeExclude[k]
                            		$scope.selectTypeInfoShow[excludeIndex]=false;
                            	}
                            }
                        
                            //是否使用保留模式
                            if($scope.seatConfig.showReserveTicketModel){
                            	$scope.showReserveTicketModel=!!$scope.seatConfig.showReserveTicketModel;
                            }
                                
                            selectSeatNum = 0;//选中座位的数量
                            selectSeatIdInfo = {};//选中的座位ID与座位信息的映射关系
                            currentSelectSeatInfo = [];
                            seatIdInfo = {};//所有座位ID与座位信息的映射关系
                            resourceIdInfo = {};

                            //高度自适应，最小高度450
                            svg_min_height = seatConfig.heightMin;
                            svg_exclude_height = seatConfig.heightExclude;
                            svg_exclude_height_full = seatConfig.heightExcludeFull;

                            //座位SVG相关参数
                            svg_params = {};
                            currentTransform = angular.copy(defaultTransform);
                            currentTransform2 = angular.copy(defaultTransform);

                            // 是否显示缩略图
                            $scope.show_thumbnail = false;
                            // 是否全屏
                            $scope.showFullscreen = true;
                            // 选中的票档
                            $scope.selectPrice = {};

                            // 工具栏中各个子栏的显示状态
                            $scope.showStates = new Array(6);
                            var i, j;
                            for (i in seatConfig.showType) {
                                j = seatConfig.showType[i];
                                $scope.showStates[j] = true;
                            }

                            // 是否支持反选选择
                            $scope.showStates[5] = seatConfig.selectInvertType == 1;
                            //增加是否显示保留票的选择选项
                            $scope.showStates[6] = seatConfig.reserveSelect;
                            
                            // 是否处于反选
                            $scope.invertModel = false;
                            //座号，锁定，预订，销售中
                            $scope.seatNoV = false;
                            $scope.lockV = false;
                            $scope.preserveV = false;
                            $scope.sellingV = false;
                            $scope.scStates = [];//各种座位类型的状态
                            // 选座方式
                            $scope.selectType = seatConfig.selectType;
                            // 是否显示座位信息框
                            $scope.show_infobox = false;
                            // 信息框信息
                            $scope.infoboxSeat = {};
                            // 加载等待框
                            $scope.show_progress = true;

                            resizeSvgSeat();
                            //加载楼层数据操作
                            loadFloorCtrl();
                        }

                        //事件监听
                        //更新座位信息监听
                        $scope.$on("updateSeatInfo-" + attrs.mapName,function (event,info){
                            for(var i=0;i<info.length;i++){
                                var curSeatId = info[i].seatId;
                                var itemSeatInfo = seatIdInfo[curSeatId];
                                var itemSelectSeatInfo = selectSeatIdInfo[curSeatId];
                                var seatDom = document.querySelector('use.'+SeatUtil.ELEMENT_CLASS.SEAT+'[seat_id="' + curSeatId + '"]');
                                switch(info[i].state){
                                    case 1: //选中
                                        if(!itemSelectSeatInfo){
                                            handleSeatSelect(itemSeatInfo,seatDom,true);
                                        }
                                    break;
                                    case 2: //可售
                                        //未售的状态才能使用
                                        if(seatIdInfo[curSeatId]['goodSaleState'] == 1) {
                                            itemSeatInfo['goodSaleState'] = 1;
                                            seatIdInfo[curSeatId]['goodSaleState'] = 1;
                                            var color = itemSeatInfo.color;
                                            seatDom.setAttribute("fill",color);
                                            handleSeatSelect(itemSeatInfo,seatDom,false);
                                        }
                                    break;
                                    case 3: //置灰
                                        seatDom.setAttribute("fill","#EBEBEB");
                                        //seatIdInfo[curSeatId]['goodSaleState'] = 3;
                                        handleSeatSelect(itemSeatInfo,seatDom,false);
                                    break;
                                }

                                
                            }

                            //$scope.afterSelect({
                            //    currentSelectSeatInfo: currentSelectSeatInfo,
                            //    selectSeatIdInfo: selectSeatIdInfo,
                            //    allSeatIdInfo: seatIdInfo
                            //});

                        })
                        //座位选择监听
                        $scope.$on("selectSeat-" + attrs.mapName, function (event, selectInfo) {
                            var selectable = selectInfo.selectable;
                            var _seatInfos = selectInfo.seatInfos;
                            var i = 0,
                                seatDom, seatId, _seatInfo, seatInfo, iterFlag;
                            for (i in _seatInfos) {
                                _seatInfo = _seatInfos[i];
                                seatId = _seatInfo.seatId;
                                seatDom = document.querySelector('use.'+SeatUtil.ELEMENT_CLASS.SEAT+'[seat_id="' + seatId + '"]');
                                seatInfo = seatIdInfo[seatId];

                                //设置座位回显样式
                                if (selectable === true && _seatInfo.selectStyle) {
                                    seatConfig.selectStyle = _seatInfo.selectStyle;
                                }

                                iterFlag = handleSeatSelect(seatInfo, seatDom, selectable);
                                if (iterFlag == -1) {
                                    break;
                                }
                            }

                            // 处理完后恢复初始设置
                            setSeatConfig($scope.seatConfig);

                            //选择之后的回调
                            $scope.afterSelect({
                                currentSelectSeatInfo: currentSelectSeatInfo,
                                selectSeatIdInfo: selectSeatIdInfo,
                                allSeatIdInfo: seatIdInfo
                            });
                        });

                        //清空选择监听
                        $scope.$on("clearSeat-" + attrs.mapName, function (event, preventCallback) {
                            var i = 0,
                                seatDom, seatId, seatInfo;
                            for (i in selectSeatIdInfo) {
                                seatInfo = selectSeatIdInfo[i];
                                seatId = seatInfo.seatId;
                                seatDom = document.querySelector('use.'+SeatUtil.ELEMENT_CLASS.SEAT+'[seat_id="' + seatId + '"]');

                                handleSeatSelect(seatInfo, seatDom, false);
                            }
                            
                            if (preventCallback != true) {
                                //选择之后的回调
                                $scope.afterSelect({
                                    currentSelectSeatInfo: currentSelectSeatInfo,
                                    selectSeatIdInfo: selectSeatIdInfo,
                                    allSeatIdInfo: seatIdInfo
                                });
                            }
                        });

                        //重新加载座位 监听
                        $scope.$on("reload-" + attrs.mapName, function (event) {
                            loadSeatMap();
                        });

                        //重新设置 监听
                        $scope.$on("setConfig-" + attrs.mapName, function (event, customSeatConfig) {
                            var key, config;
                            for (key in customSeatConfig) {
                                config = customSeatConfig[key];
                                $scope.seatConfig[key] = config;
                            }
                        });

                        //设置套票的边框 监听
                        $scope.$on("setCouponBorder-" + attrs.mapName, function (event, couponSeatIdInfo) {
                            var seatId, seatInfo, seatDom;
                            //# 设置border属性 # 计算出边框组
                            for (seatId in couponSeatIdInfo) {
                                seatInfo = couponSeatIdInfo[seatId];
                                seatInfo.border = true;
                                seatDom = document.querySelector('use.'+SeatUtil.ELEMENT_CLASS.SEAT+'[seat_id="' + seatId + '"]');

                                //TODO:加边框，先用紫色边框代替
                                seatDom.setAttribute('stroke', "purple");
                                seatDom.setAttribute('stroke-width', "3");
                                seatDom.setAttribute('stroke-dasharray', "5,2");
                            }
                        });

                        //设置套票的边框 监听
                        $scope.$on("removeCouponBorder-" + attrs.mapName, function (event, couponSeatIdInfo) {
                            var seatId, seatInfo, seatDom;
                            //# 设置border属性 # 计算出边框组
                            for (seatId in couponSeatIdInfo) {
                                seatInfo = seatIdInfo[seatId];
                                seatDom = document.querySelector('use.'+SeatUtil.ELEMENT_CLASS.SEAT+'[seat_id="' + seatId + '"]');

                                //TODO:去掉套票相关信息
                                delete seatInfo.border;
                                seatDom.setAttribute('stroke', '#000');
                                seatDom.setAttribute('stroke-width', '1');
                                seatDom.removeAttribute('stroke-dasharray');

                                //去掉选中相关信息
                                delete seatInfo.selected;
                                delete seatInfo.otherInfo;
                                var selectIcon = document.querySelector('use.' + ICON_ID.COUPON + '[seat_id="' + seatId + '"]');
                                getSeatLayer().removeChild(selectIcon);

                                //!从选中列表中移除
                                delete selectSeatIdInfo[seatId];

                                //handleSeatSelect(seatInfo, seatDom,false);
                            }
                        });

                        function addCouponSeats(seatList){
                            //将套票座位成组的进行操作
                            var couponGroupIdFlag = {};
                            var couponSeatInfo = {};
                            var index,len,seatDom,seatId,seatInfo;
                            for (index = 0, len = seatList.length; index < len; index++) {
                                seatDom = seatList[index];
                                seatId = seatDom.getAttribute('seat_id');
                                seatInfo = seatIdInfo[seatId];
                                if(seatInfo.couponPriceId && seatInfo.couponPriceId != '0'){
                                    couponGroupIdFlag[seatInfo.couponGroupId] = seatInfo;
                                    couponSeatInfo[seatId] = true;
                                }
                            }
                            var couponGroupId,tmpSeatList;
                            for(couponGroupId in couponGroupIdFlag){
                                seatInfo = couponGroupIdFlag[couponGroupId];
                                tmpSeatList = document.querySelectorAll('use.'+SeatUtil.ELEMENT_CLASS.SEAT+'[coupon_group_id="'+couponGroupId+'"]');
                                for(index=0,len=tmpSeatList.length;index<len;index++){
                                    seatDom = tmpSeatList[index];
                                    if(!couponSeatInfo[seatDom.getAttribute('seat_id')]){
                                        seatList.push(seatDom);
                                    }
                                }
                            }
                        }

                        function bindListeners() {
                            svg_seat = getSvgSeat();
                            svg_thumbnail = getSvgThumbnail();
                            thumbnailSelector = getThumbnailSelector();
                            seatSelector = getSeatSelector();

                            //鼠标右键拖拽
                            svg_seat.addEventListener('mousedown', mouseDownHandler);
                            svg_seat.addEventListener('mousemove', mouseMoveHandler);
                            svg_seat.addEventListener('mouseup', mouseUpHandler);
                            svg_seat.addEventListener('mousewheel', mouseWheelHandler);

                            //禁用右键菜单
                            $(svg_seat).bind('contextmenu', function (evt) { return false; });
                            $(svg_thumbnail).bind('contextmenu', function (evt) { return false; });

                            //鼠标右键拖拽
                            thumbnailSelector.addEventListener('mousedown', mouseDownHandler2);
                            thumbnailSelector.addEventListener('mousemove', mouseMoveHandler2);
                            thumbnailSelector.addEventListener('mouseup', mouseUpHandler2);

                            //禁用右键菜单
                            $(thumbnailSelector).bind('contextmenu', function (evt) {
                                return false;
                            });

                            //鼠标移入，禁用滚动条
                            //svg_seat.addEventListener('mouseenter', disableScroll);
                            //svg_seat.addEventListener('mouseleave', enableScroll);
                            svg_thumbnail.addEventListener('mouseenter', disableScroll);
                            svg_thumbnail.addEventListener('mouseleave', enableScroll);


                            //为座位添加单击事件
                            $(floorGEl).delegate('use,path,text', 'click', function (event) {
                                var clickSeatInfo,clickSeatDom,seatId,selectType,rowList;

                                seatId = event.target.getAttribute('seat_id');
                                // 排除
                                if(!seatId){
                                    return;
                                }
                                
                                //获得当前选中的座位信息
                                clickSeatInfo = seatIdInfo[seatId];
                                //如果这个座位非【未售出】  则我认为他有可能是预定或售出
                                if(maizuoSystemId && maizuoSystemId == 1002){
                                	$scope.saleGoodInfo = {
                                			"goodId":'',
                                			"eventId":'',
                                			"projectId":'',
                                			"saleState":'',
                                			"saleStateName":'',
                                			"saleChannelId":'',
                                			"saleChannelName":'',
                                			"saleOperatorId:":'',
                                			"saleOperatorName":'',
                                			"orderId":'',
                                			"orderType":'',
                                			"orderTypeName":'',
                                			"saleTime":'',
                                			"billTypeId":'',
                                			"billTypeName":'',
                                			"customerId":'',
                                			"customerTel":'',
                                			"customerName":'',
                                			"customerCard":'',
                                			"searchResult":	''
                                    }
                                    /* if(clickSeatInfo.goodSaleState != null && clickSeatInfo.goodSaleState != 1){*/
                                	if(clickSeatInfo.goodSaleState != null && clickSeatInfo.goodSaleState != 1  || clickSeatInfo.goodOperationState == 1) {
                            			$scope.show_infobox = false; //隐藏浮层
                                		if(clickSeatInfo.goodId != null && clickSeatInfo.goodId > 0){
                                			var salePromise = OssCommonService.findGoodSaleResult({"goodId":clickSeatInfo.goodId,"eventId":$scope.eventId});
                                			salePromise.then(function (data) {
                                    			if(data && data != null){
                                    				$scope.saleGoodInfo = {
                                            			"goodId":data.goodId,
                                            			"eventId":data.eventId,
                                            			"projectId":data.projectId,
                                            			"saleState":data.saleState,
                                            			"saleStateName":data.saleStateName,
                                            			"saleChannelId":data.saleChannelId,
                                            			"saleChannelName":data.saleChannelName,
                                            			"saleOperatorId:":data.saleOperatorId,
                                            			"saleOperatorName":data.saleOperatorName,
                                            			"orderId":data.orderId,
                                            			"orderType":data.orderType,
                                            			"orderTypeName":data.orderTypeName,
                                            			"saleTime":data.saleTime,
                                            			"billTypeId":data.billTypeId,
                                            			"billTypeName":data.billTypeName,
                                            			"customerId":data.customerId,
                                            			"customerTel":data.customerTel,
                                            			"customerName":data.customerName,
                                            			"customerCard":data.customerCard,
                                            			"searchResult":	data.searchResult
                                                    }
                                    			}
                                			}, function () {
                                                MaiDialog.error("服务器异常");
                                            });
                                		}else{
                                			console.log("非商品");
                                		}
                                		/**
                                		 * 弹出对话框
                                		 */
                                		$("#show_seatSaleInfo").modal("show");
                                		$scope.seatNumber = $scope.infoboxSeat.rowName + '排' + $scope.infoboxSeat.seatName;
                                    	return;
                                    }
                                }
                                

                                //选择之前的回调
                                var tmpSeatConfig = $scope.beforeSelect({
                                    selectSeatIdInfo: selectSeatIdInfo
                                });

                                if (tmpSeatConfig === false) {
                                    leftRegionSelect = false;
                                    return;
                                }

                                if (typeof tmpSeatConfig == 'object') {
                                    setSeatConfig(tmpSeatConfig);
                                }


                                //selectType: 选择方式-->0|1|2|3|4(0框选1单选2排选3单排4双排)
                                selectType = $scope.selectType;
                                switch (selectType) {
                                    //排选
                                    case 2:
                                    //单号排选
                                    case 3:
                                    //双号排选
                                    case 4:
                                        rowList = {};
                                        rowList[clickSeatInfo.rowId] = {
                                            boundId : clickSeatInfo.boundId,
                                            rowId : clickSeatInfo.rowId
                                        };
                                        handleSeatRowsSelect(rowList);
                                        break;

                                    //单选
                                    case 1:
                                    default:
                                    	//获得选中的dom数据元素
                                        clickSeatDom = document.querySelector('use.'+SeatUtil.ELEMENT_CLASS.SEAT+'[seat_id="' + clickSeatInfo.seatId + '"]');
                                        handleSeatListSelect([clickSeatDom]);
                                }

                            });

                            $(floorGEl).delegate('use,path,text', 'mouseover', function (event) {
                                var seatId = event.target.getAttribute('seat_id');
                                if(!seatId){
                                    return;
                                }

                                //显示悬浮框
                                var infobox = document.querySelector(".svg_infobox"),
                                    svgOffset = $(svg_seat).offset();
                                infobox.style.left = (event.pageX - svgOffset.left + 3) + "px";
                                infobox.style.top = (event.pageY - svgOffset.top + 53) + "px";

                                //根据测试需求门店浮框向右下5px
                                if (seatConfig.outLetFlag) {
                                    infobox.style.left = (event.pageX - svgOffset.left + 8) + "px";
                                    infobox.style.top = (event.pageY - svgOffset.top + 58) + "px";
                                }

                                var seatInfo = seatIdInfo[seatId];

                                if(seatInfo.lockLevel > 0 && seatInfo.lockLevel > seatConfig.lock_level) {
                                    seatInfo.lockUser = "***";
                                }

                                $scope.$apply(function () {
                                    $scope.show_infobox = true;
                                    $scope.infoboxSeat = seatInfo;
                                });

                                //infobox.style.display = 'block';
                            });
                            $(floorGEl).delegate('use,path,text', 'mouseout', function (event) {
                                $scope.$apply(function () {
                                    $scope.show_infobox = false;
                                });
                            });


                            svg_thumbnail.addEventListener('mousewheel',function(event){
                                if (event.wheelDelta > 0 || event.detail < 0) {
                                    var centerO = getPointOnSvgSeat(event.clientX, event.clientY);
                                    var centerX = centerO.centerX,
                                        centerY = centerO.centerY;
                                    zoomOutHandler(centerX, centerY, svg_params.dltScale/10);
                                }
                            });


                            //为缩略图的区域增加凸显效果
                            $(floorGEl2).delegate('.'+SeatUtil.ELEMENT_CLASS.RESOURCE,'mouseover',function(event){
                                var standElement = event.target;
                                var resourceId = standElement.getAttribute("static_resource_id");
                                var resource = resourceIdInfo[resourceId];
                                if(resource.staticResourceType == SeatUtil.STATIC_RESOURCE_TYPE.TEXT_BOUND){
                                    standElement = document.querySelector('.svg_thumbnail .'+SeatUtil.ELEMENT_CLASS.RESOURCE+'[static_resource_id="'+resource.staticResourceDesc+'"]');
                                    if(!standElement) return;
                                }

                                if(standElement.getAttribute("bound") != 'true'){
                                    return;
                                }

                                //突出显示
                                var showStandElement = document.querySelector('.svg_seat .'+SeatUtil.ELEMENT_CLASS.RESOURCE+'[static_resource_id="'+standElement.getAttribute('static_resource_id')+'"]');
                                standElement.style.fill = '#009';
                                showStandElement.style.fill = '#009';
                            });
                            $(floorGEl2).delegate('.'+SeatUtil.ELEMENT_CLASS.RESOURCE,'mouseout',function(event){
                                var standElement = event.target;
                                var resourceId = standElement.getAttribute("static_resource_id");
                                var resource = resourceIdInfo[resourceId];
                                if(resource.staticResourceType == SeatUtil.STATIC_RESOURCE_TYPE.TEXT_BOUND){
                                    standElement = document.querySelector('.svg_thumbnail .'+SeatUtil.ELEMENT_CLASS.RESOURCE+'[static_resource_id="'+resource.staticResourceDesc+'"]');
                                    if(!standElement) return;
                                }

                                if(standElement.getAttribute("bound") != 'true'){
                                    return;
                                }

                                //取消突出显示
                                var showStandElement = document.querySelector('.svg_seat .'+SeatUtil.ELEMENT_CLASS.RESOURCE+'[static_resource_id="'+standElement.getAttribute('static_resource_id')+'"]');
                                standElement.style.fill = boundColor;
                                showStandElement.style.fill = boundColor;
                            });
                            //缩略图区域点击之后跳转。。
                            $(floorGEl2).delegate('.'+SeatUtil.ELEMENT_CLASS.RESOURCE,'click',function(event){
                                var standElement = event.target;
                                var resourceId = standElement.getAttribute("static_resource_id");
                                var resource = resourceIdInfo[resourceId];
                                if(resource.staticResourceType == SeatUtil.STATIC_RESOURCE_TYPE.TEXT_BOUND){
                                    standElement = document.querySelector('.svg_thumbnail .'+SeatUtil.ELEMENT_CLASS.RESOURCE+'[static_resource_id="'+resource.staticResourceDesc+'"]');
                                    if(!standElement) return;
                                }

                                if(standElement.getAttribute("bound") != 'true'){
                                    return;
                                }

                                var x, y,centerX,centerY,clickPoint,ratio,newScale,oScale,dltScale,
                                viewBoxWidth,viewBoxHeight,svgW,svgH;

                                var sRect = standElement.getBoundingClientRect();
                                var rTopLeft = getPointOnSvgThumbnail(sRect.left, sRect.top);
                                var rRightBottom = getPointOnSvgThumbnail(sRect.right, sRect.bottom);
                                x = rTopLeft.centerX + (rRightBottom.centerX - rTopLeft.centerX) / 2;
                                y = rTopLeft.centerY + (rRightBottom.centerY - rTopLeft.centerY) / 2;


                                centerX = svg_params.viewBoxWidth / 2 + svg_params.viewBoxMinX;
                                centerY = svg_params.viewBoxHeight / 2 + svg_params.viewBoxMinY;

                                currentTransform.scale = 1;
                                currentTransform.tx = centerX - x;
                                currentTransform.ty = centerY - y;

                                setFloorGelTransform();


                                svgW = $(svg_seat).width();
                                svgH = $(svg_seat).height();
                                viewBoxWidth = svg_params.viewBoxWidth;
                                viewBoxHeight = svg_params.viewBoxHeight;
                                if (svgW > svgH) {
                                    ratio = viewBoxHeight / svgH;
                                } else {
                                    ratio = viewBoxWidth / svgW;
                                }

                                newScale = ratio < 1 ? 1 : ratio;
                                if(newScale > 1){
                                    addScale(x + currentTransform.tx, y + currentTransform.ty ,Math.abs(newScale-1));
                                }else if(newScale <= 1){
                                    decreaseScale(x,y,Math.abs(newScale-1));
                                }
                            });
                        }

                        $scope.fullScreenSvg = fullScreenSvg;
                        $scope.ExitSvgFullscreen = ExitSvgFullscreen;
                        $scope.clickZoomHandler = clickZoomHandler;
                        $scope.fullScreenSvg = fullScreenSvg;
                        $scope.backToInitStatus = backToInitStatus;

                        $scope.changeSelectPrice = function(index){
                            $scope.selectPrice = $scope.priceList[index];
                        };

                        $scope.changeSelectType = function(selectType){
                            $scope.selectType = selectType;
                        };

                        // 加载状态图标
                        $scope.toggleStateSeats = function (toggle, seatType) {
                            if (toggle) {
                                loadStateSeats(seatType);
                            } else {
                                unloadStateSeats(seatType);
                            }
                        };

                        // 加座座位类型
                        $scope.toggleSeatClassState = function(toggle,seatClassId){
                            //对应的座位
                            var seatDoms, i,len,seatDom;
                            seatDoms = document.querySelectorAll('.'+SeatUtil.ELEMENT_CLASS.SEAT+'[seat_class_id="'+seatClassId+'"]');
                            for(i=0,len=seatDoms.length;i<len;i++){
                                seatDom = seatDoms.item(i);
                                seatDom.style.display = toggle?'inline-block':'none';

                                //锁定，销售中，预定，默认不显示
                                var seatId = seatDom.getAttribute('seat_id');
                                var rmLPIconArr = document.querySelectorAll("[seat_id='"+seatId+"'][icon_id]");
                                var rmLPIconArrLen = rmLPIconArr.length;
                                if(rmLPIconArrLen > 0) {
                                    for(var j = 0; j < rmLPIconArrLen; j++) {
                                        rmLPIconArr[j].style.display = toggle?'inline-block':'none';
                                    }
                                }

                                //默认不显示座号
                                var noNum =  document.querySelectorAll("text[seat_id='"+seatId+"']");
                                var noNumLen = noNum.length;
                                if(noNumLen  > 0) {
                                    for(var m = 0; m < noNumLen; m++) {
                                        noNum[m].style.display = toggle?'inline-block':'none';
                                    }
                                }
                            }
                        };

                        // 切换座号显示
                        $scope.toggleSeatNo = function(toggle){
                            loadSeatNo(toggle);
                        };

                        // 设置用户自定义的配置
                        function setSeatConfig(customSeatConfig) {
                            var key, config;
                            for (key in customSeatConfig) {
                                config = customSeatConfig[key];
                                seatConfig[key] = config;
                            }

                            if (typeof customSeatConfig.otherInfo == 'undefined') {
                                delete seatConfig.otherInfo;
                            }
                        }

                        function mouseDownHandler(evt) {
                            mDownClientX = evt.clientX;
                            mDownClientY = evt.clientY;

                            //右键
                            if (evt.button == 2) {
                                rightDragFlag = true;

                                mDownTx = currentTransform.tx;
                                mDownTy = currentTransform.ty;
                                return;
                            }

                            //左键
                            if (seatConfig.selectable) {//可选(时框选始终支持)
                                leftRegionSelect = true;

                                //选择之前的回调
                                var tmpSeatConfig = $scope.beforeSelect({
                                    selectSeatIdInfo: selectSeatIdInfo
                                });

                                if (tmpSeatConfig === false) {
                                    leftRegionSelect = false;
                                    return;
                                }

                                if (typeof tmpSeatConfig == 'object') {
                                    setSeatConfig(tmpSeatConfig);
                                }

                                //显示选择框
                                seatSelector.style.display = 'block';
                                //svg_seat.style.cursor = 'crosshair';

                                //如果正选才设置颜色
                                if (!$scope.invertModel) {
                                    var color = seatConfig.selectRectColor || $scope.selectRectColor;
                                    seatSelector.setAttribute('fill', color);
                                }

                                //获得选择框起始坐标
                                var currentPoint = getPointOnSvgSeat(evt.clientX, evt.clientY);
                                mDownRectX = currentPoint.centerX;
                                mDownRectY = currentPoint.centerY;

                                return;
                            }

                            //无需再继续处理
                            evt.preventDefault();
                        }

                        function mouseMoveHandler(evt) {
                            mMoveClientX = evt.clientX;
                            mMoveClientY = evt.clientY;
                            
                            if (evt.button == 2 && rightDragFlag) {
                                var svg_seat = getSvgSeat();
                                var svgW = $(svg_seat).width(),
                                    svgH = $(svg_seat).height(),
                                    ratio;
                                if (svgW > svgH) {
                                    ratio = svg_params.viewBoxHeight / svgH;
                                } else {
                                    ratio = svg_params.viewBoxWidth / svgW;
                                }
                                svg_params.ratio = ratio;
                                var dltClientX = mMoveClientX - mDownClientX,
                                    dltClientY = mMoveClientY - mDownClientY;

                                /*if(dltClientX == 0 && dltClientY == 0) {
                                 return;
                                 }*/

                                currentTransform.tx = mDownTx + dltClientX * svg_params.ratio;
                                currentTransform.ty = mDownTy + dltClientY * svg_params.ratio;

                                setFloorGelTransform();
                                return;
                            }

                            //左键
                            if (leftRegionSelect) {
                                //设置座位选择框的宽高位置
                                var tempO = getPointOnSvgSeat(event.clientX, event.clientY),
                                    tempX = tempO.centerX,
                                    tempY = tempO.centerY;
                                
                                var rectW = Math.abs(tempX - mDownRectX),
                                    rectH = Math.abs(tempY - mDownRectY),
                                    rectX = tempX < mDownRectX ? tempX : mDownRectX,
                                    rectY = tempY < mDownRectY ? tempY : mDownRectY;

                                seatSelector.setAttribute("x", rectX);
                                seatSelector.setAttribute("y", rectY);
                                seatSelector.setAttribute("width", rectW);
                                seatSelector.setAttribute("height", rectH);
                            }
                        }

                        function mouseUpHandler(evt) {
                            //右键
                            if (evt.button == 2) {
                                rightDragFlag = false;
                                return;
                            }

                            mUpClientX = evt.clientX;
                            mUpClientY = evt.clientY;

                            //左键

                            //判断鼠标是否移动了
                            /*if(mUpClientX - mDownClientX == 0 && mUpClientY - mDownClientY == 0) {
                             evt.preventDefault();
                             return;
                             }*/

                            if (leftRegionSelect) {
                                leftRegionSelect = false;

                                //筛选出所有被选中的座位，并执行回调
                                var tmpList = document.querySelectorAll('use.'+SeatUtil.ELEMENT_CLASS.SEAT);
                                var seatList = [];

                                //计算正方形覆盖范围
                                var minX = seatSelector.x.baseVal.value;
                                var minY = seatSelector.y.baseVal.value;
                                var maxX = seatSelector.x.baseVal.value + seatSelector.width.baseVal.value;
                                var maxY = seatSelector.y.baseVal.value + seatSelector.height.baseVal.value;

                                // 隐藏选择框
                                seatSelector.style.display = 'none';
                                seatSelector.setAttribute('width', '0');
                                //svg_seat.style.cursor = 'auto';
                                //选框颜色
                                seatSelector.setAttribute('fill', $scope.selectRectColor);

                                //如果选框范围太小，直接不处理
                                if (maxX - minX > 5 && maxY - minY > 5) {
                                    var rootCTM = svg_seat.getScreenCTM(),
                                        pointSvg = svg_seat.createSVGPoint(),
                                        index, seatId, seatInfo,seatList,rowIdInfo,selectType,
                                        length, seatDom, cCTM, pointNew, sx, sy;
                                    rowIdInfo = {};
                                    seatList = [];
                                    selectType = $scope.selectType;
                                    for (index = 0, length = tmpList.length; index < length; index++) {
                                        seatDom = tmpList[index];

                                        pointSvg.x = seatDom.x.baseVal.value;
                                        pointSvg.y = seatDom.y.baseVal.value;

                                        cCTM = seatDom.getScreenCTM();
                                        pointNew = pointSvg.matrixTransform(rootCTM.inverse().multiply(cCTM));
                                        sx = pointNew.x;
                                        sy = pointNew.y;

                                        //座位在框选范围之内
                                        if (sx >= minX && sx <= maxX && sy >= minY && sy <= maxY) {
                                            seatId = seatDom.getAttribute('seat_id');

                                            seatInfo = seatIdInfo[seatId];

                                            //单选状态下
                                            if(selectType == 1){
                                                if(checkSeatClassHidden(seatDom,seatId)) continue;

                                                seatList.push(seatDom);
                                                continue;
                                            }

                                            rowIdInfo[seatInfo.rowId] = {
                                                boundId : seatInfo.boundId,
                                                rowId : seatInfo.rowId
                                            };

                                        }

                                    }
                                }

                                if(selectType == 1){
                                    handleSeatListSelect(seatList);
                                    return;
                                }

                                handleSeatRowsSelect(rowIdInfo);
                            }
                        }

                        //对多排排座位的(去)选中操作
                        function handleSeatRowsSelect(rowIdInfo){
                            var rowId,rowInfo,tmpList,selectType,seatList,index,len,seatDom,seatId,seatInfo;

                            selectType = $scope.selectType;

                            seatList = [];
                            for(rowId in rowIdInfo){
                                rowInfo = rowIdInfo[rowId];
                                tmpList = document.querySelectorAll('use.'+SeatUtil.ELEMENT_CLASS.SEAT+'[bound_id="' + rowInfo.boundId + '"][row_id="' + rowId + '"]');
                                for (index = 0, len = tmpList.length; index < len; index++) {
                                    seatDom = tmpList.item(index);
                                    seatId = seatDom.getAttribute('seat_id');

                                    if(checkSeatClassHidden(seatDom,seatId)) continue;

                                    seatInfo = seatIdInfo[seatId];
                                    if(selectType == 2 || (selectType == 3 && seatInfo.seatNo%2 == 1) || (selectType == 4 && seatInfo.seatNo%2 == 0)){
                                        seatList.push(seatDom);
                                    }
                                }
                            }

                            handleSeatListSelect(seatList);
                        }

                        function checkSeatClassHidden(seatDom,seatId){
                            // 如果是隐藏的(并且之前没有被选中的)座位，跳过
                            if(!seatId){
                                seatId = seatDom.getAttribute('seat_id');
                            }
                            return seatDom.style.display == 'none' && !selectSeatIdInfo[seatId];
                        }

                        //对一组座位的(去)选中操作  
                        //选中座位操作
                        function handleSeatListSelect(seatList){
                            var index,seatDom,seatId,seatInfo,seatIdDom,tmpList;

                            if(seatList.length > 0 ){//设置套票操作
                                addCouponSeats(seatList);
                            }

                            currentSelectSeatInfo.length = 0;
                            seatIdDom = {};
                            for (index in seatList) {
                                seatDom = seatList[index];
                                seatId = seatDom.getAttribute("seat_id");
                                seatIdDom[seatId] = seatDom;
                                seatInfo = seatIdInfo[seatId];
                                currentSelectSeatInfo.push(seatInfo); 
                            }


                            //选择时的回调
                            var tmpSeatConfig = $scope.onSelect({
                                currentSelectSeatInfo: currentSelectSeatInfo,
                                selectSeatIdInfo: selectSeatIdInfo,
                                allSeatIdInfo: seatIdInfo,
                                invertModel: $scope.invertModel
                            });

                            if (tmpSeatConfig === false) {
                                // 恢复初始设置
                                setSeatConfig($scope.seatConfig);
                                return;
                            }

                            if (typeof tmpSeatConfig == 'object') {
                                setSeatConfig(tmpSeatConfig);
                            }

                            //如果有座位落入框选范围之内，则处理
                            if (seatList.length > 0) {

                                var iterFlag;
                                for (seatId in seatIdDom) {
                                    seatDom = seatIdDom[seatId];
                                    seatInfo = seatIdInfo[seatId];

                                    iterFlag = handleSeatSelect(seatInfo, seatDom);
                                    if (iterFlag == -1) {
                                        break;
                                    }
                                }

                                //释放内存
                                seatIdDom = null;
                                seatList = null;
                                tmpList = null;

                                //选择之后的回调
                                $scope.afterSelect({
                                    currentSelectSeatInfo: currentSelectSeatInfo,
                                    selectSeatIdInfo: selectSeatIdInfo,
                                    allSeatIdInfo: seatIdInfo
                                });
                            }

                            // 恢复初始设置
                            setSeatConfig($scope.seatConfig);
                        }

                        // 对单个座位的(去)选中操作
                        // 当个座位选中操作
                        function handleSeatSelect(seatInfo, seatDom, selectable) {
                        	if (selectable == false) {
                        		console.log('==================================================================================');
                        	}
                            var seatId = seatInfo.seatId,
                                iconX = seatInfo.x - 10,
                                iconY = seatInfo.y - 10;

                            if(!seatInfo.state){
                                return 0;
                            }

                            if (typeof seatConfig.selectCondition == 'string') {
                            	//选中的条件判断
                                if (!eval(seatConfig.selectCondition) || seatInfo.couponGrayFlag) { //套票一个档位下架置灰，关联的套票置灰
                                    return 0;//0表示不处理
                                }
                            }

                            var selectIcon, isCustomSelect;
                            isCustomSelect = selectable === true || selectable === false;


                            if(seatConfig.selectStyleType==3){
                            	//当前选择的是保留票模式
                                //正选
                                if (selectable === true || $scope.invertModel == false) {
                                	if (seatInfo.reversedTicket==false) {
    	                            	var icon=$scope.reverseTicketSelect.id==1?ICON_ID.REVC:ICON_ID.REVJ;
    	                            	selectIcon = createIcon(seatId, iconX, iconY, icon);
    	                            	getSeatLayer().appendChild(selectIcon);
    	                            	//选中的模式
    	                            	//zhouwei 1场馆 2机位
    	                            	seatInfo.reversedTicketType=$scope.reverseTicketSelect.id;
    	                            	seatInfo.reversedTicket=true;
                                	}
                                }
                                //反选
                                if (selectable === false || $scope.invertModel == true) {
	                            	var icon=$scope.reverseTicketSelect.id == 1 ? ICON_ID.REVC : ICON_ID.REVJ;
                                    selectIcon = document.querySelector('[icon_id="'+icon+'"][seat_id="'+seatId+'"]');
                                    if (selectIcon) {
                                    	selectIcon.remove();
                                        seatInfo.reversedTicket = false;
                                    } 
                                }
                            }

                            //未选中
                            if (!seatInfo.selected) {
                                if (seatInfo.eventId == $scope.eventId) {
	                                if (false == selectable) {
	                                    return 0;
	                                }
	
	                                //背景为灰色不可选中特意为门店锁票限制
	                                if(document.querySelector('use[seat_id="'+seatInfo.seatId+'"]').getAttribute('fill') ==  '#EBEBEB' && seatConfig.outLetFlag) {
	                                    return 0;
	                                }
	
	                                if (!isCustomSelect) {
	                                    // 支持反选，且反选按钮被勾选
	                                    if (seatConfig.selectInvertType == 1 && $scope.invertModel) {
	                                        return 0;
	                                    }
	                                }
	
	                                //选择数量限制
	                                if (seatConfig.selectMaxCount != -1 && selectSeatNum >= seatConfig.selectMaxCount) {
	                                    MaiDialog.alert(seatConfig.selectMaxTip);
	                                    return -1;// -1表示中断循环
	                                }

                                    seatInfo.selected = true;

                                    if (seatConfig.selectStyleType == 1) {
                                        selectIcon = createIcon(seatId, iconX, iconY, seatConfig.selectStyle);
                                        getSeatLayer().appendChild(selectIcon);
                                    } else if (seatConfig.selectStyleType == 2) {
                                        selectIcon = createCustomIcon(seatId, iconX, iconY, seatConfig.selectStyle);
                                        getSeatLayer().appendChild(selectIcon);
                                    } else if (seatConfig.selectStyleType == 0) {
                                        //选择后设置颜色，锁定状态和默认颜色（未选择档位），禁止设置颜色
                                        if(seatInfo.lockLevel < 1 && seatConfig.selectStyle != '#EBEBEB') {
                                            seatDom.setAttribute('fill', seatConfig.selectStyle);
                                        }
                                    }

                                    //记录选中座位
                                    selectSeatNum++;
                                    seatInfo.selectStyle = seatConfig.selectStyle;
                                    if (seatConfig.otherInfo) {
                                        seatInfo.otherInfo = seatConfig.otherInfo;
                                    }
                                    selectSeatIdInfo[seatId] = seatInfo;
                                } else {
                                	console.log('asdfasfdasdfasdfasfd');
                                }
                            }
                            //已选中
                            else {

                                // 不支持反选模式
                                if (!isCustomSelect && seatConfig.selectInvertType == 0) {
                                    if (seatConfig.selectStyleType == 1) {
                                        selectIcon = document.querySelector('use.'+seatConfig.selectStyle+'[seat_id="'+seatId+'"]');
                                        getSeatLayer().removeChild(selectIcon);
                                    } else if (seatConfig.selectStyleType == 2) {
                                        selectIcon = document.querySelector('path.customIcon[seat_id="'+seatId+'"]');
                                        getSeatLayer().removeChild(selectIcon);
                                    } else if (seatConfig.selectStyleType == 0) {
                                        //var color = seatInfo.color || '#EBEBEB';
                                        var color = '#EBEBEB';
                                        seatDom.setAttribute("fill", color);
                                    }

                                    //取消记录选中座位
                                    selectSeatNum--;
                                    delete seatInfo.selected;
                                    delete seatInfo.selectStyle;
                                    delete seatInfo.otherInfo;
                                    delete selectSeatIdInfo[seatId];
                                }

                                //支持反选模式
                                if (isCustomSelect || seatConfig.selectInvertType == 1) {

                                    //正选
                                    if (selectable === true || $scope.invertModel == false) {
                                        if (seatConfig.selectStyleType == 1) {
                                            selectIcon = document.querySelector('use.'+seatConfig.selectStyle+'[seat_id="'+seatId+'"]');
                                            getSeatLayer().removeChild(selectIcon);
                                            selectIcon = createIcon(seatId, iconX, iconY, seatConfig.selectStyle);
                                            getSeatLayer().appendChild(selectIcon);

                                            seatInfo.selectStyle = seatConfig.selectStyle;
                                            if (seatConfig.otherInfo) {
                                                seatInfo.otherInfo = seatConfig.otherInfo;
                                            }
                                        } else if (seatConfig.selectStyleType == 2) {
                                            selectIcon = document.querySelector('path.customIcon[seat_id="'+seatId+'"]');
                                            getSeatLayer().removeChild(selectIcon);
                                            selectIcon = createCustomIcon(seatId, iconX, iconY, seatConfig.selectStyle);
                                            getSeatLayer().appendChild(selectIcon);

                                            seatInfo.selectStyle = seatConfig.selectStyle;
                                            if (seatConfig.otherInfo) {
                                                seatInfo.otherInfo = seatConfig.otherInfo;
                                            }
                                        } else if (seatConfig.selectStyleType == 0) {
                                            //锁定状态和默认颜色（未选择档位）禁止设置颜色
                                            if(seatInfo.lockLevel < 1 && seatConfig.selectStyle != '#EBEBEB') {
                                                seatDom.setAttribute('fill', seatConfig.selectStyle);
                                                seatInfo.selectStyle = seatConfig.selectStyle;
                                                if (seatConfig.otherInfo) {
                                                    seatInfo.otherInfo = seatConfig.otherInfo;
                                                }
                                            }

                                        }

                                    }
                                    //反选
                                    if (selectable === false || $scope.invertModel == true) {
                                        if (seatConfig.selectStyleType == 1) {
                                            selectIcon = document.querySelector('use.'+seatConfig.selectStyle+'[seat_id="'+seatId+'"]');
                                            getSeatLayer().removeChild(selectIcon);
                                        } else if (seatConfig.selectStyleType == 2) {
                                            selectIcon = document.querySelector('path.customIcon[seat_id="'+seatId+'"]');
                                            getSeatLayer().removeChild(selectIcon);
                                        } else if (seatConfig.selectStyleType == 0) {
                                            //var color = seatInfo.color || '#EBEBEB';
                                            if(seatInfo.lockLevel < 1){
                                                var color = '#EBEBEB';
                                                seatDom.setAttribute("fill", color);
                                            }
                                        }

                                        //取消记录选中座位
                                        selectSeatNum--;
                                        delete seatInfo.selected;
                                        delete seatInfo.selectStyle;
                                        delete seatInfo.otherInfo;
                                        delete selectSeatIdInfo[seatId];
                                    }

                                }

                            }
                            return 1;
                        }

                        function mouseWheelHandler(evt) {
                            var centerO = getPointOnSvgSeat(evt.clientX, evt.clientY);
                            var centerX = centerO.centerX,
                                centerY = centerO.centerY;

                            if (evt.wheelDelta < 0 || evt.detail > 0) {
                                zoomInHandler(centerX, centerY, svg_params.dltScale/3);
                            } else {
                                zoomOutHandler(centerX, centerY, svg_params.dltScale/3);
                            }

                            evt.preventDefault();
                        }

                        function mouseDownHandler2(evt) {
                            mDownClientX2 = evt.clientX;
                            mDownClientY2 = evt.clientY;

                            //左键
                            if (evt.button == 0) {
                                rightDragFlag2 = true;

                                mDownTx2 = currentTransform2.tx;
                                mDownTy2 = currentTransform2.ty;
                                return;
                            }
                        }

                        function mouseMoveHandler2(evt) {
                            if (evt.button == 0 && rightDragFlag2) {
                                var svg_thumbnail = getSvgThumbnail();
                                var svgW = $(svg_thumbnail).width(),
                                    svgH = $(svg_thumbnail).height(),
                                    ratio;
                                if (svgW > svgH) {
                                    ratio = svg_params.viewBoxHeight / svgH;
                                } else {
                                    ratio = svg_params.viewBoxWidth / svgW;
                                }

                                var dltClientX = evt.clientX - mDownClientX2,
                                    dltClientY = evt.clientY - mDownClientY2;
                                currentTransform2.tx = mDownTx2 + dltClientX * ratio;
                                currentTransform2.ty = mDownTy2 + dltClientY * ratio;

                                currentTransform.tx = -currentTransform2.tx * currentTransform.scale;
                                currentTransform.ty = -currentTransform2.ty * currentTransform.scale;

                                getFloorGEl().setAttribute("transform", SeatUtil.encodeTransform(currentTransform));
                                getThumbnailSelector().setAttribute("transform", SeatUtil.encodeTransform(currentTransform2));
                                return;
                            }

                        }

                        function mouseUpHandler2(evt) {
                            //右键
                            if (evt.button == 0) {
                                rightDragFlag2 = false;
                                return;
                            }
                        }


                        function loadFloorCtrl() {
                            $scope.show_progress = true;
                            //陈波添加购物车类型
                            var cartType=$scope.shoppingCartType?$scope.shoppingCartType:0;
                            //加载楼层
                            var floorPromise = PmsCommonService.loadFloorAndSeats($scope.eventId,$scope.channelId, $scope.orderId, $scope.advanceOrderId,cartType);
                            floorPromise.then(function (data) {
                                //加载楼层
                                loadFloor(data);

                                loadPriceCtrl();
                            }, function () {
                                MaiDialog.error("服务器异常");
                            });
                        }

                        //加载票档
                        function loadPriceCtrl() {
                            //加载票档
                            var pricePromise = PmsCommonService.getPriceInfoList({"eventId":$scope.eventId,"channelId":currentChannelId ? currentChannelId : 0});
                            pricePromise.then(function (data) {
                                $scope.priceList.length = 0;
                                for (var i in data) {
                                    $scope.priceList.push(data[i]);
                                }
                                $scope.selectPrice = data[0];

                                loadCouponPriceCtrl();

                            }, function () {
                                console.log("查询票档失败");
                            });
                        }

                        //加载套票档位
                        function loadCouponPriceCtrl() {
                            //加载票档
                            var pricePromise = PmsCommonService.findPriceCouponList({eventId: $scope.eventId});
                            pricePromise.then(function (data) {
                                $scope.priceCoupons.length = 0;
                                for (var i in data) {
                                    $scope.priceCoupons.push(data[i]);
                                }

                                loadSeatClassCtrl();
                            }, function () {
                                console.log("查询套票失败");
                            });
                        }

                        //加载座位类型
                        function loadSeatClassCtrl(){
                            //加载票档
                            var promise = PmsCommonService.findAllSeatClass();
                            promise.then(function (data) {
                                $scope.seatClasses.length = 0;
                                var i;
                                for(i in data){
                                    $scope.seatClasses.push(data[i]);
                                }

                                //不用显示正座
                                if($scope.seatClasses[0].seatClassName == '正座') {
                                    $scope.seatClasses.splice(0, 1);
                                }

                                //初始化就加载的图标
                                var seatTypes = seatConfig.seatType,seatType;
                                for(i in seatTypes){
                                    seatType = seatTypes[i];

                                    switch (seatType) {
                                        case SEAT_TYPE.LOCK:
                                            $scope.lockV = true;
                                            break;
                                        case SEAT_TYPE.PRESERVE:
                                            $scope.preserveV = true;
                                            break;
                                        case SEAT_TYPE.SELLING:
                                            $scope.sellingV = true;
                                            break;
                                        case SEAT_TYPE.REVTICKET:
                                            $scope.reversedTicketV = true;
                                            break;
                                    }

                                    loadStateSeats(seatType);
                                }
                                //座位第二图标的处理
                                //座位第二图标目前只有一个：
                                //根据seatConfig.selectStyleType == 3 (在保留票设置功能内)
                                //    seatInfo.reversedTicket true/false (标记是否是保留票）

                                //显示第二图标
                                loadSecendStateSeats()
                            
                                //加载完成之后的回调
                                $scope.afterLoad({
                                    priceList: $scope.priceList,
                                    priceCoupons: $scope.priceCuppons,
                                    seatClasses: data,
                                    selectSeatIdInfo: selectSeatIdInfo,
                                    allSeatIdInfo: seatIdInfo
                                });

                                reSizeSeats();
                                if (++loadSeatMapCount == 1) {
                                    bindListeners();
                                }

                                calculateSvgHeight();

                                $scope.show_progress = false;
                            }, function () {
                                console.log("查询座位类型失败");
                            });
                        }

                        //加载楼层
                        function loadFloor(floorList) {
                            var floorGroupEL = getFloorGEl(), floorGroupEL2 = getFloorGEl2(),
                                floor, i, floorDom, thumbnailSelector,
                                seatWebVOList, staticResourceList;

                            //清空所有的子元素
                            floorGroupEL.innerHTML = '';
                            floorGroupEL2.innerHTML = '';

                            for (i in floorList) {
                                floor = floorList[i];

                                // 只使用一个楼层来加载所有的座位
                                if (i < 2) {
                                    floorDom = document.createElementNS(SVG_NS, "g");
                                }

                                floorDom.setAttribute("floor_id", floor.floorId);
                                floorDom.setAttribute("floor_num", floor.floorNum);
                                floorDom.setAttribute("transform", floor.transform || transFormDefault);
                                floorDom.setAttribute("class", "svg_floor_g");

                                //加载座位
                                seatWebVOList = floor.seatWebVOList;
                                loadSeats(seatWebVOList, floorDom);

                                //加载静态资源
                                staticResourceList = floor.staticResourceWebVOList;
                                if (staticResourceList && staticResourceList.length > 0) {
                                    // 如果是区域文本，则忽略
                                    loadStaticResource(staticResourceList, floorDom);
                                }

                                floorGroupEL.appendChild(floorDom);

                                //隐藏底图上标注(字母、文字)
                                var venStaticRes  = document.querySelectorAll('.floor_group_el [isboundname]');
                                for(var s = 0; s< venStaticRes.length; s++) {
                                    venStaticRes[s].style.display = 'none';
                                }

                                //加载缩略图
                                if (i == 0) {
                                    $scope.show_thumbnail = true;

                                    floorDom = document.createElementNS(SVG_NS, "g");
                                    floorDom.setAttribute("floor_id", floor.floorId);
                                    floorDom.setAttribute("transform", floor.transform || transFormDefault);
                                    floorDom.setAttribute("class", "svg_floor_g2");

                                    //加载静态资源
                                    if (staticResourceList && staticResourceList.length > 0) {
                                        loadStaticResource2(staticResourceList, floorDom);
                                    }

                                    //添加区域选择灰框
                                    thumbnailSelector = document.createElementNS(SVG_NS, "rect");
                                    //暂时隐藏
                                    thumbnailSelector.style.display = 'none';
                                    thumbnailSelector.setAttribute("class", "thumbnail_selector");
                                    thumbnailSelector.setAttribute("fill", "rgba(0,0,255,0.2)");

                                    floorGroupEL2.appendChild(floorDom);
                                    floorGroupEL2.appendChild(thumbnailSelector);
                                }
                            }

                        }


                        //加载座位
                        function loadSeats(seatWebVOList, floorDom) {
                            var j, seatId, seatInfo, seat, couGroupIdArr =[];
                            var seatFragment = document.createDocumentFragment();

                            //记录下架的套票couponGroupId，套票一个档位下架置灰，关联的套票置灰
                            couGroupIdArr.length = 0;
                            //先拿到下架套票票的额couponGroupId的集合
                            if(seatConfig.outLetFlag) {
                                for(j in seatWebVOList) {
                                    seatInfo = seatWebVOList[j];
                                    seatId = seatInfo.seatId;
                                    if(seatInfo.couponGroupId && seatInfo.goodOperationState == 1) {
                                        couGroupIdArr.push(seatInfo.couponGroupId)
                                    }
                                }
                                //数组去重
                                $.unique(couGroupIdArr);
                            }

                            for (j in seatWebVOList) {
                                seatInfo = seatWebVOList[j];
                                seatId = seatInfo.seatId;

                                //打印座位信息
                                //console.log('=============>goodId: ' + seatInfo.goodId + ', goodClass: ' + seatInfo.goodClass + ', goodsMark: ' + seatInfo.goodsMark);
                                //console.log('===============>goodOperationState: ' + seatInfo.goodOperationState + ', goodSaleState: ' + seatInfo.goodSaleState);
                                //console.log('=================>ticketLevelId: ' + seatInfo.ticketLevelId + ', couponPriceId: ' + seatInfo.couponPriceId + ', couponState: ' + seatInfo.couponState);
                                //if(seatInfo.couponGroupId != '0' && seatInfo.couponGroupId != 'null'){
                                //    console.log('=============>couponPriceId: ' + seatInfo.couponPriceId + ", couponGroupId:"+seatInfo.couponGroupId+",couponPriceAlias:"+seatInfo.couponPriceAlias);
                                //}

                                //套票一个档位下架置灰，关联的套票置灰，关联的套票先加一个标志位
                                if(couGroupIdArr.length > 0 && seatInfo.couponGroupId != 0 && couGroupIdArr.indexOf(seatInfo.couponGroupId) !=-1) {
                                    seatInfo.couponGrayFlag = true;
                                }

                                //缓存座位数据
                                seatIdInfo[seatId] = seatInfo;

                                if (typeof seatConfig.initSelectCondition == 'string') {
                                    if (eval(seatConfig.initSelectCondition)) {
                                        selectSeatIdInfo[seatId] = seatInfo;
                                        seatInfo.selected = true;//表示被选中
                                        seatInfo.selectStyle = seatInfo.color;
                                    }
                                }

                                seat = createSeat(seatInfo);
                                seatFragment.appendChild(seat);
                            }
                            floorDom.appendChild(seatFragment);
                        }

                        //加载静态资源
                        function loadStaticResource(staticResourceList, floorDom) {
                            var i, staticResourceVO, staticResourceAttr, staticResourceJQ, staticResourceJS, staticTagName, staticDom;
                            for (i in staticResourceList) {
                                staticResourceVO = staticResourceList[i];

                                //建立ID与详情的映射关系
                                resourceIdInfo[staticResourceVO.staticResourceId] = staticResourceVO;

                                staticResourceAttr = staticResourceVO.staticResourceAttr;
                                staticResourceJQ = $(staticResourceAttr);
                                staticResourceJS = staticResourceJQ.get(0);
                                staticTagName = staticResourceJS.tagName;
                                staticDom = document.createElementNS(SVG_NS, staticTagName.toLowerCase());
                                $.each(staticResourceJS.attributes, function (i, attrib) {
                                    staticDom.setAttribute(attrib.name, attrib.value);
                                });

                                //如果是区域提示，则不显示
                                if(staticResourceVO.staticResourceType != SeatUtil.STATIC_RESOURCE_TYPE.TEXT_BOUND){
                                    staticDom.innerHTML = staticResourceJS.innerHTML;
                                }

                                staticDom.setAttribute("static_resource_id", staticResourceVO.staticResourceId);
                                floorDom.appendChild(staticDom);
                            }
                        }

                        //加载缩略区的静态资源
                        var boundColor;
                        function loadStaticResource2(staticResourceList, floorDom) {
                            var i, staticResourceVO, staticResourceAttr, staticResourceJQ, staticResourceJS, staticTagName, staticDom;
                            for (i in staticResourceList) {
                                staticResourceVO = staticResourceList[i];
                                staticResourceAttr = staticResourceVO.staticResourceAttr;
                                staticResourceJQ = $(staticResourceAttr);
                                staticResourceJS = staticResourceJQ.get(0);
                                staticTagName = staticResourceJS.tagName;
                                staticDom = document.createElementNS(SVG_NS, staticTagName.toLowerCase());
                                $.each(staticResourceJS.attributes, function (i, attrib) {
                                    staticDom.setAttribute(attrib.name, attrib.value);
                                });
                                staticDom.innerHTML = staticResourceJS.innerHTML;

                                //获得区域提示颜色
                                if(!boundColor && staticDom.getAttribute('bound') == 'true'){
                                    boundColor = staticDom.style.fill || staticDom.getAttribute('fill');
                                }

                                staticDom.setAttribute("static_resource_id", staticResourceVO.staticResourceId);
                                floorDom.appendChild(staticDom);
                            }

                            if(!boundColor){
                                boundColor = '#ffffff';
                            }
                        }

                        //加载显示/移除座号(flag为true是表示加载，否则移除座号显示)
                        function loadSeatNo(flag) {
                            var seatList, i, len, seatInfo, seatDom, seatId, noDom, seatLayer;
                            seatLayer = getSeatLayer();
                            if (flag === true) {
                                seatList = document.querySelectorAll('use.'+SeatUtil.ELEMENT_CLASS.SEAT);
                                for (i = 0, len = seatList.length; i < len; i++) {
                                    seatDom = seatList[i];
                                    seatId = seatDom.getAttribute('seat_id');
                                    seatInfo = seatIdInfo[seatId];

                                    // 如果有座号
                                    if (seatInfo && seatInfo.seatNo > 0) {
                                        noDom = createSeatNo(seatInfo, seatInfo.x, seatInfo.y + 4);

                                        //加座，包厢等单独判断
                                        if(seatInfo.seatClassId > 0 && document.querySelector("."+SeatUtil.ELEMENT_CLASS.SEAT+"[seat_id='"+seatInfo.seatId+"']").style.display == 'none') {
                                            noDom.style.display = 'none';

                                        }

                                        seatLayer.appendChild(noDom);
                                    }
                                }
                                return;
                            }

                            //移除
                            var noDoms = document.querySelectorAll('text.seat_no');
                            for (i = 0, len = noDoms.length; i < len; i++) {
                                noDom = noDoms[i];
                                seatLayer.removeChild(noDom);
                            }
                        }

                        //加载锁定/预订/销售中/已售/联票座位
                        function loadStateSeats(seatStateType) {
                            // 获得内置图标ID
                            var iconId;
                            switch (seatStateType) {
                                case SEAT_TYPE.LOCK:
                                    iconId = ICON_ID.LOCK;
                                    break;
                                case SEAT_TYPE.PRESERVE:
                                    iconId = ICON_ID.PRESERVE;
                                    break;
                                case SEAT_TYPE.SELLING:
                                    iconId = ICON_ID.SELLING;
                                    break;
                                case SEAT_TYPE.UNION:
                                    iconId = ICON_ID.UNION;
                                    break;
                                case SEAT_TYPE.COUPON:
                                    iconId = ICON_ID.COUPON;
                                    break;
                                case SEAT_TYPE.REVTICKET: //保留票 陈波添加
                                	iconId=[ ICON_ID.REVC,ICON_ID.REVJ ];
                                	break;
                            }
                            // 遍历所有座位生成图标
                            if (iconId) {
                                var seatList, i, len, seatInfo, seatDom, seatId, iconDom, seatLayer, showIcon;
                                seatList = document.querySelectorAll('use.'+SeatUtil.ELEMENT_CLASS.SEAT);
                                seatLayer = getSeatLayer();
                                len = seatList.length;

                                for (i = 0; i < len; i++) {
                                    seatDom = seatList[i];
                                    seatId = seatDom.getAttribute('seat_id');
                                    seatInfo = seatIdInfo[seatId];


                                    //判断哪种情况下（筛除不可能有icon的数据），才会有icon, seatInfo.couponGrayFlag标志位,套票一个档位下架置灰，关联的套票置灰
                                    var judgingCon;
                                    if(seatConfig.outLetFlag){ //门店销售 add by 陈波(若当前座位为保留票,且操作员不具有销售保留票的权限则不显示)||(seatInfo.reversedTicketId>0&&!seatConfig.allowSaleRevTicket)
                                        judgingCon = seatInfo.goodSaleState == 1 && seatInfo.lockLevel < 0 || seatInfo.goodOperationState == 1 || seatInfo.couponGrayFlag||(seatInfo.reversedTicketId>0&&!seatConfig.allowSaleRevTicket&&seatInfo.goodsMark==1);
                                    } else {
                                        judgingCon = typeof seatConfig.excludeCondition == 'string' && eval(seatConfig.excludeCondition);
                                    }

                                    if (judgingCon) {
                                        continue;
                                    }

                                    //条件判断
                                    showIcon = false;
                                    switch (seatStateType) {
                                        case SEAT_TYPE.LOCK:
                                            if(seatConfig.outLetFlag) {
                                                showIcon = (seatInfo.lockLevel > 0 && seatInfo.goodSaleState !=2) && ( seatInfo.lockLevel > 0 && seatInfo.goodSaleState != 4);
                                            } else {
                                                showIcon = seatInfo.lockLevel > 0;
                                            }
                                            //换成gray锁
                                            iconId = showIcon && (seatConfig.lock_level < seatInfo.lockLevel || seatConfig.lock_level == seatInfo.lockLevel && seatInfo.levelVisible == 2) ? ICON_ID.LOCK_GRAY: ICON_ID.LOCK;
                                            break;
                                        case SEAT_TYPE.PRESERVE:
                                            if(!seatConfig.outLetFlag) {
                                                showIcon = seatInfo.lockLevel < 1 && seatInfo.goodSaleState == 4;
                                            } else {
                                                showIcon = seatInfo.goodSaleState == 4;
                                            }
                                            break;
                                        case SEAT_TYPE.SELLING:
                                            if(!seatConfig.outLetFlag) {
                                                showIcon = seatInfo.lockLevel < 1 && seatInfo.goodSaleState == 2
                                            } else {
                                                showIcon = seatInfo.goodSaleState == 2;
                                            }
                                            break;
                                        case SEAT_TYPE.UNION:
                                            //显示联票图标多个条件(只有未售状态才能显示联票图标) wxm 2016.8.23
                                            showIcon = seatInfo.goodsMark == 2 && seatInfo.goodSaleState == 1 && seatInfo.lockLevelId == 0 && seatInfo.reversedTicketId == null;
                                            break;
                                        case SEAT_TYPE.COUPON:
                                            showIcon = seatInfo.couponPriceId && seatInfo.couponPriceId != '0';
                                            break;
                                        case SEAT_TYPE.REVTICKET: //添加保留票
                                            showIcon = seatInfo.reversedTicketId && seatInfo.reversedTicket && seatInfo.reversedTicketType && seatInfo.beforePriceId;
                                        	break;
                                    }
                                    if (showIcon) {
                                    	if(seatStateType!=SEAT_TYPE.REVTICKET){
	                                        iconDom = createIcon(seatId, seatInfo.x - 10, seatInfo.y - 10, iconId);
	                                        //在有seatClassId的情况下，且隐藏的情况下，图标都隐藏
	                                        if(seatInfo.seatClassId > 0 && document.querySelector("."+SeatUtil.ELEMENT_CLASS.SEAT+"[seat_id='"+seatInfo.seatId+"']").style.display == 'none') {
	                                            iconDom.style.display = 'none';
	                                        }
	                                        seatLayer.appendChild(iconDom);
                                    	}else{
                                    		
                                    		//创建保留票操作,添加颜色
                                    		  iconId=seatInfo.reversedTicketType == 1 ? ICON_ID.REVC : ICON_ID.REVJ
                                    		  iconDom = createIcon(seatId, seatInfo.x - 10, seatInfo.y - 10, iconId);
                                    		  seatLayer.appendChild(iconDom);
                                    		  
                                    		  if(seatInfo.goodSaleState==1){
                                    			  seatDom.setAttribute("fill", seatInfo.color);
                                    		  }

                                        }

                                        //门店，加背景色
                                        if(seatConfig.outLetFlag) {
                                            if(iconId == ICON_ID.LOCK || iconId == ICON_ID.LOCK_GRAY || iconId == ICON_ID.PRESERVE ||  iconId == ICON_ID.SELLING) {
                                            	if(seatInfo.goodSaleState==1){
                                            	   seatDom.setAttribute("fill", seatInfo.color);
                                            	}
                                            }
                                        }

                                    }
                                }
                            }
                        }

                        function loadSecendStateSeats(seatStateType) {
                            // 遍历所有座位生成图标
                            var seatList, i, len, seatInfo, seatDom, seatId, iconId, iconDom, seatLayer, showIcon;
                            seatList = document.querySelectorAll('use.'+SeatUtil.ELEMENT_CLASS.SEAT);
                            seatLayer = getSeatLayer();

                            len = seatList.length;
                            for (i = 0; i < len; i++) {
                                seatDom = seatList[i];
                                seatId = seatDom.getAttribute('seat_id');
                                seatInfo = seatIdInfo[seatId];
                                showIcon =( (seatConfig.selectStyleType == 3)||(seatConfig.showReversedTicket))&& (seatInfo.reversedTicket==true);
                                //条件判断
                                if (showIcon) {
                                    var iconId = seatInfo.reversedTicketType == 1 ? ICON_ID.REVC : ICON_ID.REVJ;
                                    iconDom = createIcon(seatId, seatInfo.x - 10, seatInfo.y - 10, iconId);
                                    seatLayer.appendChild(iconDom);
                                }
                            }
                        }

                //卸载锁定/预订/销售中/已售/联票座位
                        function unloadStateSeats(seatStateType) {
                            // 获得内置图标ID
                            var iconId;
                            switch (seatStateType) {
                                case SEAT_TYPE.LOCK:
                                    iconId = ICON_ID.LOCK;
                                    break;
                                case SEAT_TYPE.PRESERVE:
                                    iconId = ICON_ID.PRESERVE;
                                    break;
                                case SEAT_TYPE.SELLING:
                                    iconId = ICON_ID.SELLING;
                                    break;
                                case SEAT_TYPE.UNION:
                                    iconId = ICON_ID.UNION;
                                    break;
                                case SEAT_TYPE.REVTICKET:
                                	iconId=[ ICON_ID.REVC,ICON_ID.REVJ ];
                                	break;
                            }
                            // 遍历所有座位生成图标
                            if (iconId) {
                                var seatLayer, iconList, i, len, iconDom, seatDom, seatId,one,two;
                                seatLayer = getSeatLayer();
                                
                                if(iconId instanceof Array){
                               	 one = document.querySelectorAll('[class^='+ICON_ID.REVC+']');
                               	 two = document.querySelectorAll('[class^='+ICON_ID.REVJ+']');
                               	 
                               	 //修改显示座位图
                               	 if(one&&one.length>0){
                               		 for(i=0;i<one.length;i++){
                                   		 seatDom = iconDom = one[i];
                                         seatLayer.removeChild(iconDom);
                                         seatId = seatDom.getAttribute('seat_id');
                                         $("use[seat_id="+seatId+"]").attr('fill','#EBEBEB');
                                   	 }
                               	 }
                                 
                               	 //修改显示座位图
                               	 if(two&&two.length>0){
                               		 for(i=0;i<two.length;i++){
                                   		 seatDom = iconDom = two[i];
                                         seatLayer.removeChild(iconDom);
                                         seatId = seatDom.getAttribute('seat_id');
                                         $("use[seat_id="+seatId+"]").attr('fill','#EBEBEB');
                                   	 } 
                               	 }
                               
                               }
                                else{
	                                if(iconId == ICON_ID.LOCK) {
	                                    iconList = document.querySelectorAll('[class^='+iconId+']');
	                                } else {
	                                    iconList = document.querySelectorAll('use.' + iconId);
	                                }
	                                for (i = 0, len = iconList.length; i < len; i++) {
	                                    seatDom = iconDom = iconList[i];
	                                    seatLayer.removeChild(iconDom);

	                                    //门店，去除背景色
	                                    seatId = seatDom.getAttribute('seat_id');
	                                    if(seatConfig.outLetFlag) {
	                                        if(iconId == ICON_ID.LOCK || iconId == ICON_ID.LOCK_GRAY || iconId == ICON_ID.PRESERVE ||  iconId == ICON_ID.SELLING) {
	                                            $("use[seat_id="+seatId+"]").attr('fill','#EBEBEB');
	                                        }
	                                    }

	                                }
                                }

                            }
                        }

                        //创建座位
                        function createSeat(seatInfo) {
                            var defaultColor = '#EBEBEB';
                            var seatDom = document.createElementNS(SVG_NS, "use");
                            seatDom.setAttribute("seat_id", seatInfo.seatId);
                            seatDom.setAttribute("x", seatInfo.x);
                            seatDom.setAttribute("y", seatInfo.y);
                            seatDom.setAttribute("bound_id", seatInfo.boundId);
                            seatDom.setAttribute("row_id", seatInfo.rowId);
                            seatDom.setAttributeNS(SVG_XLINK, "xlink:href", 'common/images/svg/defs.svg#seat_circle');
                            seatDom.setAttribute('class', SeatUtil.ELEMENT_CLASS.SEAT);
                            seatDom.setAttribute("fill", defaultColor);

                            // 判断该座位是否在“例外状态座位的”范围内
                            var isException = false,
                                seatId = seatDom.getAttribute('seat_id'),
                                i,statefulSeat,key;

                            if(angular.isArray($scope.statefulSeats) && $scope.statefulSeats.length > 0){
                                for(i in $scope.statefulSeats){
                                    statefulSeat = $scope.statefulSeats[i];
                                    if(statefulSeat.seatId == seatId){
                                        isException = true;

                                        //需要设置其他状态
                                        for(key in statefulSeat){
                                            seatInfo[key] = statefulSeat[key];
                                        }

                                        break;
                                    }
                                }
                            }

                            //如果不加载座位状态，直接返回
                            if(!isException && !seatConfig.showSeatState){
                                return seatDom;
                            }

                            //设置座位状态
                            seatInfo.state = true;

                            //套票属性
                            if(seatInfo.couponGroupId && seatInfo.couponGroupId != '0'){
                                seatDom.setAttribute("coupon_group_id", seatInfo.couponGroupId);
                            }

                            //不在门店，在门店的非特殊座位正常显示
                            if (typeof seatConfig.excludeCondition == 'string' && eval(seatConfig.excludeCondition) && !seatConfig.outLetFlag || typeof seatConfig.excludeCondition == 'string' && eval(seatConfig.excludeCondition) && seatConfig.outLetFlag && seatInfo.seatClassId== 0) {
                                return seatDom;
                            }
                            
                            //只要是保留票初始化的时候就不显示 ,在门店不显示
                            if(seatConfig.outLetFlag&&seatInfo.reversedTicketId&&seatInfo.goodsMark==1){
                            	return seatDom;
                            }

                            //颜色
                            var color = seatInfo.color || defaultColor;
                            //在门店中,锁票背景色默认灰色
                            if(seatConfig.outLetFlag && seatInfo.lockLevel > 0 || seatConfig.outLetFlag && seatInfo.seatClassId > 0 && seatInfo.goodSaleState != 1) {
                                color = defaultColor;
                            }

                            if(seatConfig.showSaleState){
                                // 不渲染的情况：锁定、已售、联票子场次
                                /*if (seatInfo.goodOperationState == 3  || (seatInfo.goodClass == 1 && seatInfo.goodsMark == 2)) {
                                 color = defaultColor;
                                 //已售,销售中,预订：“深灰”
                                 } else */
                                /*if (seatInfo.goodSaleState == 3 || seatInfo.goodSaleState == 2 || seatInfo.goodSaleState == 4) {
                                 color = '#999999';
                                 }

                                 if(seatInfo.goodSaleState == 3) {
                                 color = '#999999';
                                 }*/

                                if(seatInfo.goodSaleState != 1 && seatConfig.pmsFlag) {
                                    color = defaultColor;
                                }

                                //包厢、加座的情况下，需要控制下  预订单、订单需要控制
                                if(seatInfo.goodSaleState == 3 && seatInfo.seatClassId > 0 && (!$scope.orderId || !$scope.advanceOrderId)) {
                                    color = defaultColor;
                                }
                            }

                            //如果是已下架状态，显示黑框(联票比较特殊需要特殊处理) wxm 2016.8.23
                            if (seatInfo.goodOperationState == 1 && seatInfo.goodsMark != 2 && !seatConfig.pmsFlag) {
                                seatDom.setAttribute('stroke', "#000");
                                seatDom.setAttribute('stroke-width', "1");
                            }

                            //联票子场次已售不画黑框  wxm 2016.8.23 wxm 2016.8.23
                            if (seatConfig.pmsFlag && eval(seatConfig.selectCondition)) {
                                seatDom.setAttribute('stroke', "#000");
                                seatDom.setAttribute('stroke-width', "1");
                            }

                            //套票显示
                            if (seatInfo.couponPriceId && seatInfo.couponPriceId != '0') {
                                //TODO:加边框，先用紫色边框代替
                                /*  seatDom.setAttribute('stroke', "purple");
                                 seatDom.setAttribute('stroke-width', "3");*/
                                //seatDom.setAttribute('stroke-dasharray', "5,5");

                                //设置标识量
                                seatInfo.border = true;
                            }

                            seatDom.setAttribute("fill", color);

                            //套票一个档位下架置灰，关联的套票置灰
                            if(seatInfo.couponGrayFlag) {
                                seatDom.setAttribute("fill", defaultColor);
                            }

                            //只有生产系统有座位类型显示，其他如果有座位类型，则隐藏
                            if(!seatConfig.pmsFlag &&!!seatInfo.seatClassId && seatInfo.seatClassId != '0'){
                                seatDom.style.display = 'none';
                                seatDom.setAttribute('seat_class_id',seatInfo.seatClassId);
                            }

                            return seatDom;
                        }

                        //创建小图标
                        function createIcon(seatId, x, y, iconId) {
                            var selectIcon = document.createElementNS(SVG_NS, "use");
                            selectIcon.setAttribute("x", x);
                            selectIcon.setAttribute("y", y);
                            selectIcon.setAttribute("seat_id", seatId);
                            selectIcon.setAttribute("icon_id", iconId);
                            selectIcon.setAttribute("class", iconId);
                            selectIcon.setAttributeNS(SVG_XLINK, "xlink:href", 'common/images/svg/defs.svg#' + iconId);
                            return selectIcon;
                        }

                        //创建座号
                        function createSeatNo(seatInfo, x, y) {
                            var noDom = document.createElementNS(SVG_NS, "text");
                            noDom.setAttribute("x", x);
                            noDom.setAttribute("y", y);
                            noDom.setAttribute("seat_id", seatInfo.seatId);
                            noDom.setAttribute("class", 'seat_no');
                            noDom.setAttribute("font-size", '12px');
                            noDom.setAttribute("text-anchor", 'middle');
                            //noDom.setAttributeNS(SVG_XLINK, "xlink:href", 'common/images/svg/defs.svg#seat_no');
                            noDom.innerHTML = seatInfo.seatNo;
                            var finalSeatName = seatInfo.seatNo;
                            if(seatInfo.seatName && seatInfo.seatName != seatInfo.seatNo){
                            	finalSeatName = seatInfo.seatName;
                            }
                            noDom.innerHTML = finalSeatName;
                            return noDom;
                        }

                        //创建用户自定义的小图标
                        function createCustomIcon(seatId, x, y, iconHTML) {
                            var selectIcon = $(iconHTML)[0];
                            selectIcon.setAttribute("x", x);
                            selectIcon.setAttribute("y", y);
                            var tf = SeatUtil.decodeTransform(selectIcon.getAttribute("transform"));
                            tf.tx = x;
                            tf.ty = y;
                            selectIcon.setAttribute("transform", SeatUtil.encodeTransform(tf));
                            selectIcon.setAttribute("seat_id", seatId);
                            selectIcon.setAttribute("class", "customIcon");
                            return selectIcon;
                        }

                        //滚动条 禁用 -- 恢复
                        function preventDefault(e) {
                            e.preventDefault();
                        }

                        function disableScroll() {
                            oldonmousewheel = document.onmousewheel;
                            document.onmousewheel = preventDefault;
                            isDisabled = true;
                        }

                        function enableScroll() {
                            if (!isDisabled) return;
                            document.onmousewheel = oldonmousewheel;
                            isDisabled = false;
                        }


                        //根据事件的落点获得SVG坐标系下对应的点
                        function getPointOnSvgSeat(evtOffsetX, evtOffsetY) {
                            //获得鼠标在用户坐标系中对应的坐标
                            var sv = document.getElementsByClassName("svg_seat")[0];
                            var pt1 = sv.createSVGPoint();
                            pt1.x = evtOffsetX;
                            pt1.y = evtOffsetY;
                            var pt2 = pt1.matrixTransform(sv.getScreenCTM().inverse());
                            return {
                                centerX: pt2.x,
                                centerY: pt2.y
                            };
                        }
                        //根据事件的落点获得SVG坐标系下对应的点
                        function getPointOnSvgThumbnail(evtOffsetX, evtOffsetY) {
                            //获得鼠标在用户坐标系中对应的坐标
                            var sv = document.getElementsByClassName("svg_thumbnail")[0];
                            var pt1 = sv.createSVGPoint();
                            pt1.x = evtOffsetX;
                            pt1.y = evtOffsetY;
                            var pt2 = pt1.matrixTransform(sv.getScreenCTM().inverse());
                            return {
                                centerX: pt2.x,
                                centerY: pt2.y
                            };
                        }

                        // 画布-鼠标滚轮向下-鼠标箭头所在点同步缩小
                        function zoomInHandler(pointX, pointY,cusDltScale) {
                            var minScale = svg_params.minScale;

                            var tx = currentTransform.tx,
                                ty = currentTransform.ty,
                                oScale = currentTransform.scale,
                                dltScale = cusDltScale || svg_params.dltScale;

                            if (oScale > minScale) {
                                dltScale = oScale - minScale < dltScale ? oScale - minScale : dltScale;
                                decreaseScale(pointX,pointY,dltScale);
                            }
                        }

                        // 画布-鼠标滚轮向上-鼠标箭头所在点同步放大
                        function zoomOutHandler(pointX, pointY,cusDltScale) {
                            var maxScale = svg_params.maxScale;

                            var tx = currentTransform.tx,
                                ty = currentTransform.ty,
                                oScale = currentTransform.scale,
                                dltScale = cusDltScale || svg_params.dltScale;

                            if (oScale < maxScale) {
                                dltScale = maxScale - oScale < dltScale ? maxScale - oScale : dltScale;
                                addScale(pointX,pointY,dltScale);
                            }
                        }

                        function decreaseScale(pointX,pointY,dltScale){
                            var tx = currentTransform.tx,
                                ty = currentTransform.ty,
                                oScale = currentTransform.scale;

                            currentTransform.scale = oScale - dltScale;
                            currentTransform.tx += (pointX - tx) / oScale * dltScale;
                            currentTransform.ty += (pointY - ty) / oScale * dltScale;

                            setFloorGelTransform();

                            //判断圆圈缩放的宽度，显示隐藏座号
                            var $svgWidth =  document.getElementsByTagName('use')[0].getBoundingClientRect().width;
                            if( $svgWidth < 16) {
                                //判断是否不存在座号，不存在不需要操作
                                if(!document.getElementsByTagName('text')[0]) {
                                    return false;
                                }
                                loadSeatNo(false);
                            }

                            if(currentTransform.scale <= svg_params.minScale){
                                checkThumbnailState();
                            }
                        }

                        function addScale(pointX,pointY,dltScale){
                            var tx = currentTransform.tx,
                                ty = currentTransform.ty,
                                oScale = currentTransform.scale;

                            currentTransform.scale = oScale + dltScale;
                            currentTransform.tx -= (pointX - tx) / oScale * dltScale;
                            currentTransform.ty -= (pointY - ty) / oScale * dltScale;

                            setFloorGelTransform();

                            //判断圆圈缩放的宽度，显示隐藏座号
                            var $svgWidth =  document.getElementsByTagName('use')[0].getBoundingClientRect().width;
                            if($svgWidth >= 16) {
                                //判断是否已存在座号，已存在不需要操作
                                if(document.getElementsByTagName('text')[0]) {
                                    return false;
                                }
                                loadSeatNo(true);
                            }

                            if(currentTransform.scale > 1){
                                checkThumbnailState();
                            }
                        }

                        function setFloorGelTransform(){
                            currentTransform2.scale = 1.0 / currentTransform.scale;
                            currentTransform2.tx = -currentTransform.tx * currentTransform2.scale;
                            currentTransform2.ty = -currentTransform.ty * currentTransform2.scale;

                            getFloorGEl().setAttribute("transform", SeatUtil.encodeTransform(currentTransform));
                            getThumbnailSelector().setAttribute("transform", SeatUtil.encodeTransform(currentTransform2));
                        }

                        // 根据显示区域的缩放程度
                        var thumbnailState = 1;//1. 小 2.大
                        function checkThumbnailState(){
                            var newState = currentTransform.scale > svg_params.minScale ? 1:2;
                            if(newState == thumbnailState) return;


                            var toolTransform = $(".tool-transform"),
                                thumbnailSvg = $(getSvgThumbnail());

                            thumbnailState = newState;
                            //座位比例>=初始比例，显示缩略图；
                            if(newState == 1){
                                thumbnailSvg.animate({
                                    width: '200px',
                                    height: '157px',
                                    right: '40px'
                                });

                                toolTransform.show(200);
                                thumbnailState = 1;
                            }

                            // 座位比例<初始比例，隐藏缩略图
                            if(newState == 2){
                                thumbnailSvg.animate({
                                    width: '100%',
                                    height: '100%',
                                    right: '0px'
                                });

                                toolTransform.hide(200);
                            }

                        }

                        //调整楼层的缩放比例，使其自适应
                        function reSizeSeats() {
                            var bottomLayer = getBottomLayer(),
                                floorGroup = getFloorGEl(),
                                svg_seat = getSvgSeat(),
                                floorGroup2 = getFloorGEl2(),
                                svg_thumbnail = getSvgThumbnail(),
                                thumbnailSelector = getThumbnailSelector();
                            var bbox = bottomLayer.getBBox();

                            var viewBoxMinX, viewBoxMinY, viewBoxWidth, viewBoxHeight, centerX, centerY,
                                thresholdW, thresholdH, standardW, standardH, dltX, dltY, layerTf, layerScale;

                            var ratio,initRatio, initialSeatRadius, maxScale, minScale, dltScale, svgW, svgH;
                            svgW = $(svg_seat).width();
                            svgH = $(svg_seat).height();

                            if (bbox.width < svgW && bbox.height < svgH) {
                                viewBoxMinX = bbox.x - (svgW - bbox.width)/2;
                                viewBoxMinY = bbox.y - (svgH - bbox.height)/2;
                                viewBoxWidth = svgW;
                                viewBoxHeight = svgH;
                            } else {
                                dltX = dltY = 100;

                                viewBoxMinX = bbox.x - dltX;
                                viewBoxMinY = bbox.y - dltY;
                                viewBoxWidth = bbox.width + dltX * 2;
                                viewBoxHeight = bbox.height + dltY * 2;

                                // 判断座位能否以10px的效果显示
                                /* if (svgW > svgH) {
                                 initRatio = viewBoxHeight / svgH;
                                 } else {
                                 initRatio = viewBoxWidth / svgW;
                                 }*/
                            }
                            centerX = bbox.width / 2 + bbox.x;
                            centerY = bbox.height / 2 + bbox.y;

                            layerTf = SeatUtil.decodeTransform(bottomLayer.getAttribute('transform') || transFormDefault);
                            layerScale = layerTf.scale;
                            svg_params.layerScale = layerScale;
                            viewBoxMinX *= layerScale;
                            viewBoxMinY *= layerScale;
                            viewBoxWidth *= layerScale;
                            viewBoxHeight *= layerScale;
                            centerX *= layerScale;
                            centerY *= layerScale;

                            svg_params.viewBoxWidth = viewBoxWidth;
                            svg_params.viewBoxHeight = viewBoxHeight;
                            svg_params.viewBoxMinX = viewBoxMinX;
                            svg_params.viewBoxMinY = viewBoxMinY;
                            svg_params.centerX = centerX;
                            svg_params.centerY = centerY;
                            var viewBox_seat = viewBoxMinX + " " + viewBoxMinY + " " + viewBoxWidth + " " + viewBoxHeight;
                            svg_seat.setAttribute("viewBox", viewBox_seat);
                            svg_thumbnail.setAttribute("viewBox", viewBox_seat);

                            thumbnailSelector.setAttribute("x", viewBoxMinX);
                            thumbnailSelector.setAttribute("y", viewBoxMinY);
                            thumbnailSelector.setAttribute("width", viewBoxWidth);
                            thumbnailSelector.setAttribute("height", viewBoxHeight);

                            if (svgW > svgH) {
                                ratio = viewBoxHeight / svgH;
                            } else {
                                ratio = viewBoxWidth / svgW;
                            }
                            svg_params.ratio = ratio;

                            initialSeatRadius = 10;
                            minScale = 5 * ratio / initialSeatRadius;
                            minScale = minScale < 0.5 ? minScale : 0.5;
                            maxScale = 20 * ratio / initialSeatRadius;
                            /*//最大使得座位的显示半径为20px
                             //当前座位半径
                             var initialSeatRadius = 10;
                             //reSize之后，座位的半径
                             var currSeatRadius = 10/ratio;
                             //设置maxScale之后，半径为20,则
                             maxScale = 20/currSeatRadius;*/


                            dltScale = (maxScale - minScale) / 9;
                            svg_params.dltScale = dltScale;
                            svg_params.maxScale = maxScale;
                            svg_params.minScale = minScale;

                            //设置currentTransform
                            currentTransform = angular.copy(defaultTransform);
                            currentTransform2 = angular.copy(defaultTransform);

                            floorGroup.setAttribute("transform", SeatUtil.encodeTransform(defaultTransform));
                            thumbnailSelector.setAttribute("transform", SeatUtil.encodeTransform(defaultTransform));
                            floorGroup2.setAttribute("transform", SeatUtil.encodeTransform(defaultTransform));

                            checkThumbnailState();
                            //判断圆圈缩放的宽度，显示隐藏座号 $svgWidth不准确
                            /*                var $svgWidth =  document.getElementsByTagName('use')[0].getBoundingClientRect().width;
                             console.log($svgWidth);
                             if( $svgWidth >= 30) {
                             loadSeatNo(true);
                             }*/

                        }


                        //使SVG全屏
                        function fullScreenSvg() {
                            $scope.showFullscreen = false;
                            $(elem).css({
                                "position": "fixed",
                                "top": "0",
                                "bottom": "0",
                                "left": "0",
                                "right": "0",
                                "margin": "0",
                                "width": "100%",
                                "height": "100%",
                                "z-index": "1040"
                            });

                            //自适应控制
                            resizeSvgSeatWhenF();
                        }

                        function ExitSvgFullscreen() {
                            $scope.showFullscreen = true;
                            $(elem).css({
                                "position": "relative",
                                "top": "0",
                                "bottom": "0",
                                "left": "0",
                                "right": "0",
                                "margin": "0",
                                "width": "100%",
                                "height": "100%",
                                "z-index": "0"
                            });

                            //自适应控制
                            resizeSvgSeat();
                        }

                        function resizeSvgSeatWhenF() {
                            $(window).unbind('resize', calculateSvgHeight);
                            $(window).unbind('resize', calculateSvgHeightWhenF);
                            calculateSvgHeightWhenF();
                            $(window).resize(calculateSvgHeightWhenF);
                            //判断圆圈缩放的宽度，显示隐藏座号
                            var $svgWidth =  document.getElementsByTagName('use')[0].getBoundingClientRect().width;
                            if($svgWidth >= 16) {
                                //判断是否已存在座号，已存在不需要操作
                                if(document.getElementsByTagName('text')[0]) {
                                    return false;
                                }
                                loadSeatNo(true);
                            } else {
                                //不需要操作
                                if(!document.getElementsByTagName('text')[0]) {
                                    return false;
                                }
                                loadSeatNo(false);
                            }

                        }

                        function calculateSvgHeightWhenF() {
                            //if (!svg_exclude_height_full) return;
                            var newHeight = $(elem).height() - svg_exclude_height_full;
                            $(svg_seat).height(newHeight);
                        }

                        function resizeSvgSeat() {
                            $(window).unbind('resize', calculateSvgHeight);
                            $(window).unbind('resize', calculateSvgHeightWhenF);

                            calculateSvgHeight();
                            $(window).resize(calculateSvgHeight);

                            //判断元素是否存在，不存在不操作
                            if(document.getElementsByTagName('use') &&document.getElementsByTagName('use')[0]) {
                                var $svgWidth =  document.getElementsByTagName('use')[0].getBoundingClientRect().width;
                            } else {
                                return false;
                            }


                            if($svgWidth >= 16) {
                                //判断是否已存在座号，已存在不需要操作
                                if(document.getElementsByTagName('text')[0]) {
                                    return false;
                                }
                                loadSeatNo(true);
                            } else {
                                if(!document.getElementsByTagName('text')[0]) {
                                    return false;
                                }
                                loadSeatNo(false);
                            }

                        }

                        function calculateSvgHeight() {
                            var newHeight = $(".main-sidebar").height() - svg_exclude_height;
                            if (newHeight < svg_min_height) {
                                return;
                            }
                            $(svg_seat).height(newHeight);
                            
                            //设置档位所在位置高度
                            $(".plus_seat_wrap .dropdown-menu").css("maxHeight",newHeight- 98);
                        }


                        //点击缩放
                        function clickZoomHandler(big) {
                            var centerX = svg_params.viewBoxWidth / 2 + svg_params.viewBoxMinX;
                            var centerY = svg_params.viewBoxHeight / 2 + svg_params.viewBoxMinY;
                            if (big) {
                                zoomOutHandler(centerX, centerY);
                            } else {
                                zoomInHandler(centerX, centerY);
                            }
                        }

                        //缩放至初始状态
                        function backToInitStatus() {
                            reSizeSeats();
                            //判断圆圈缩放的宽度，显示隐藏座号
                            var $svgWidth =  document.getElementsByTagName('use')[0].getBoundingClientRect().width;
                            if( $svgWidth >= 16) {
                                loadSeatNo(true);
                            } else {
                                loadSeatNo(false);
                            }
                        }


                        //获得座位SVG DOM对象
                        function getSvgSeat() {
                            if (!svg_seat || $(svg_seat).width() == 0) {
                                svg_seat = document.querySelector('.svg_seat');
                            }
                            return svg_seat;
                        }

                        //获得楼层SVG租对象
                        function getFloorGEl() {
                            if (!floorGEl || $(floorGEl).width() == 0) {
                                floorGEl = document.querySelector('.floor_group_el');
                            }
                            return floorGEl;
                        }

                        //获得底图层 DOM对象
                        function getBottomLayer() {
                            if (!bottomLayer || $(bottomLayer).width() == 0) {
                                bottomLayer = $(".svg_floor_g").eq(0)[0];
                            }
                            return bottomLayer;
                        }
                        //获得所有楼层的综合宽高和起始位置
                        function getTotalDimension() {
                            var i,len,floorVO,floorDom,floorDoms,floorScale,bbox, x, y,x2,y2, tmpX,tmpY,tmpWidth,tmpHeight, width,height;
                            x = y = x2 = y2 = width = height = 0;
                            var floorDoms = document.querySelectorAll('.svg_floor_g');
                            for(i=0,len = floorDoms.length;i<len;i++){
                                floorDom = floorDoms.item(0);
                                bbox = floorDom.getBBox();

                                floorScale = SeatUtil.decodeTransform(bottomLayer.getAttribute('transform')).scale;
                                tmpX = bbox.x * floorScale;
                                tmpY = bbox.y * floorScale;
                                tmpWidth = bbox.width * floorScale;
                                tmpHeight = bbox.height * floorScale;

                                if(tmpX < x){
                                    x = tmpX;
                                }
                                if(tmpY < y){
                                    y = tmpY;
                                }
                                if(tmpX + tmpWidth > x2){
                                    x2 = tmpX + tmpWidth;
                                }
                                if(tmpY + tmpHeight > y2){
                                    y2 = tmpY + tmpHeight;
                                }
                                return {
                                    x: x,
                                    y: y,
                                    width: x2 -x,
                                    height: y2 - y2
                                };
                            }
                        }

                        //获得底图层 DOM对象
                        function getSeatLayer() {
                            if (!seatLayer || $(seatLayer).width() == 0) {
                                seatLayer = $(".svg_floor_g").eq(1)[0];
                            }
                            return seatLayer;
                        }


                        //获得缩略图对象
                        function getSvgThumbnail() {
                            if (!svg_thumbnail || $(svg_thumbnail).width() == 0) {
                                svg_thumbnail = document.querySelector('.svg_thumbnail');
                            }
                            return svg_thumbnail;
                        }

                        //获得缩略图楼层SVG组对象
                        function getFloorGEl2() {
                            if (!floorGEl2 || $(floorGEl2).width() == 0) {
                                floorGEl2 = document.querySelector('.floor_group_el2');
                            }
                            return floorGEl2;
                        }

                        //获得缩略图楼层SVG组对象
                        function getThumbnailSelector() {
                            if (!thumbnailSelector || $(thumbnailSelector).width() == 0) {
                                thumbnailSelector = document.querySelector('.thumbnail_selector');
                            }
                            return thumbnailSelector;
                        }

                        //获得底图层 DOM对象
                        function getBottomLayer2() {
                            if (!bottomLayer2 || $(bottomLayer2).width() == 0) {
                                bottomLayer2 = document.querySelector('.svg_floor_g2');
                            }
                            return bottomLayer2;
                        }

                        //获得座位选择框
                        function getSeatSelector() {
                            if (!seatSelector || $(seatSelector).width() == 0) {
                                seatSelector = document.querySelector(".seat_selector");
                            }
                            return seatSelector;
                        }

                    }
                };
            },
            templateUrl: rootPath + "/common/js/html/plusSeat.html"
        };
    });
});